package cn.hdu.liang.timer;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class RunWithDelay {
    private static Timer timer = new Timer();
	static public class MyTask extends TimerTask {
		@Override
		public void run() {
			System.out.println("运行了！时间为：" + new Date());
            //timer.cancel();
		}
	}
	public static void main(String[] args) {
		MyTask task = new MyTask();

		System.out.println("当前时间：" + new Date().toString());
		timer.schedule(task, 3000,1000);
	}
}
